package com.feature.core.util;

import org.apache.commons.lang3.StringUtils;

import com.feature.core.constant.Constants;
import com.feature.core.exception.ServiceException;

public class AssertUtil {

	public static void notNull(Object obj, String code, String msg) {
		if (obj == null) {
			throw new ServiceException(code, msg);
		}
	}

	public static void notBlank(String obj, String code, String msg) {
		if (StringUtils.isBlank(obj)) {
			throw new ServiceException(code, msg);
		}
	}

	public static void notBlank(Object obj, String code, String msg) {
		notNull(obj, code, msg);
		notBlank(obj.toString(), code, msg);
	}

	public static void isTrue(boolean state, String code, String msg) {
		if (!state) {
			throw new ServiceException(code, msg);
		}
	}

	public static void notNull(Object obj, String msg) {
		notNull(obj, Constants.FAIL, msg);
	}

	public static void notBlank(String obj, String msg) {
		notBlank(obj, Constants.FAIL, msg);
	}

	public static void notBlank(Object obj, String msg) {
		notBlank(obj, Constants.FAIL, msg);
	}

	public static void isTrue(boolean state, String msg) {
		isTrue(state, Constants.FAIL, msg);
	}
	
	
}
